﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
    public class XemLichVanChuyenDAO
    {
        SqlConnection cn = DataProvider.ConnectDB();

        public DataTable XemLichVanChuyen_TheoTuyenDuong(int matuyenduong, ErrorDTO error)
        {
            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand("sp_XemLichVanChuyen_theotuyenduong", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@matuyenduong", matuyenduong));
            SqlParameter output = cmd.Parameters.Add(new SqlParameter("@error", SqlDbType.NVarChar, 100));
            output.Direction = ParameterDirection.Output;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);

            error.Msg = output.Value.ToString();
            cn.Close();
            return dt;

        }

        public DataTable XemLichVanChuyen_tatca(ErrorDTO error)
        {
            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand("sp_XemLichVanChuyen_tatca", cn);
            cmd.CommandType = CommandType.StoredProcedure;
           
            SqlParameter output = cmd.Parameters.Add(new SqlParameter("@error", SqlDbType.NVarChar, 100));
            output.Direction = ParameterDirection.Output;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);

            error.Msg = output.Value.ToString();
            cn.Close();
            return dt;

        }

        public DataTable XemLicgVanChuyen_theothoigian(DateTime ngaydi,DateTime ngayden ,ErrorDTO error)
        {
            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand("sp_XemLichVanChuen_theothoigian", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@ngaydi", ngaydi));
            cmd.Parameters.Add(new SqlParameter("@ngayden", ngayden));
            SqlParameter output = cmd.Parameters.Add(new SqlParameter("@error", SqlDbType.NVarChar, 100));
            output.Direction = ParameterDirection.Output;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);

            error.Msg = output.Value.ToString();
            cn.Close();
            return dt;
        }


    }


}
